-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
polling helpers for stack plan/configuration state #953
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, there are two functions I would need to have added for the CLI if possible :)
@@ -20,6 +20,16 @@ type StackConfigurations interface { | |||
|
|||
// JSONSchemas returns a byte slice of the JSON schema for the stack configuration. | |||
JSONSchemas(ctx context.Context, stackConfigurationID string) ([]byte, error) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add an AwaitQueued? This would be helpful since only then the eventstream url is set :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added AwaitStatus
that accepts a specific status, and renamed "AwaitPrepared" to "AwaitCompleted"
stack_configuration.go
Outdated
// The channel will be closed when the stack configuration reaches a status indicating that or an error occurs. The | ||
// read will be retried dependending on the configuration of the client. When the channel is closed, | ||
// the last value will either be a terminal status or an error. | ||
func (s stackConfigurations) AwaitPrepared(ctx context.Context, stackConfigurationID string) <-chan WaitForStatusResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious what the advantage is to returning the read only channel as opposed to returning either the terminal status or error? The caller will inevitably have to write a range loop to read from it or am I missing some extra context here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait I see the examples, it allows for easier embedding within a select
.
273b98c
to
294b11b
Compare
Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes. |
Description
Stack configurations, stack plans, and stack plan operations are driven through their lifecycle through various states, and these can be repetitive and difficult to correctly handle when developing client applications. It would be really nice if the SDK provided some simple polling helpers to assist with building client applications.
Testing plan
Utilized this in canary tests. DM for details. Here's an example:
Waiting for configuration prepared:
Fan-in plans triggered by prepared configuration: